<section class="content-header">
  <h1>
    合同管理
    <small>合同相关操作</small>
  </h1>
  <ol class="breadcrumb">
    <li><a href="#/index"><i class="fa fa-dashboard"></i> 主页</a></li>
    <li class="active">合同列表</li>
  </ol>
</section>
<section class="content">
  <div class="row">
    <div class="col-xs-12">
      <div class="box">
        <div class="box-header">
          <h3 class="box-title">合同列表</h3>
          <hr>
          <div class="row">
            <div class="col-xs col-md-6">
              <div class="col-xs col-sm-4">
                <button class="btn btn-primary" privilege="添加合同" ng-click="addContract()">
                  <span>添加合同</span>
                </button>
              </div>
            </div>
            <div class="col-xs col-md-6">
              <div class="col-xs col-sm-4"></div>
              <div class="col-xs col-sm-6">
                <i class="fa fa-search"></i> <input type="text"
                                                    ng-change="changeCD();" ng-model="condition"
                                                    placeholder="单位/日期/签订人等搜索">
              </div>
            </div>
          </div>
        </div>
        <!-- /.box-header -->
        <div class="box-body">
          <table id="example2" class="table table-bordered table-hover">
            <thead>
            <tr>
              <th>产品型号</th>
              <th>单位名称</th>
              <th>合同额</th>
              <th>签订人</th>
              <th>签订日期</th>
              <th>省份</th>
              <th>物料</th>
              <th>用途</th>
              <th>行业</th>
              <th>规模</th>
              <th ng-show="opt">操作</th>
            </tr>
            </thead>
            <tbody>
            <tr ng-repeat="contract in page.recordList" style="cursor:pointer"
                ng-click="contractInfo($index);" privilege="查看合同:contractInfo">
              <td ng-bind-html="contract.productName|highlightText:condition"></td>
              <td ng-bind-html="contract.cname|highlightText:condition"></td>
              <td><span ng-bind-html="contract.money|highlightText:condition"></span>万</td>
              <td ng-bind-html="contract.signperson|highlightText:condition"></td>
              <td ng-bind-html="contract.signdate|highlightText:condition"></td>
              <td ng-bind-html="contract.provinceName|highlightText:condition"></td>
              <td ng-bind-html="contract.material|highlightText:condition"></td>
              <td ng-bind-html="contract.purposeName|highlightText:condition"></td>
              <td ng-bind-html="contract.categoryName|highlightText:condition"></td>
              <td ng-bind-html="contract.scale|highlightText:condition"></td>
              <td>
                <button privilege="删除合同" ng-click="del(contract.cid,$event)" class="btn-xs btn-danger  ">
                  <span>删除</span>
                </button>
                <button privilege="修改合同" ng-click="edit($index,$event)" class="btn btn-warning btn-xs">
                  <span>修改</span>
                </button>
              </td>
            </tr>
            </tbody>
          </table>
          <div ui-view="pagebar"></div>
        </div>
        <!-- /.box-body -->
      </div>
    </div>
  </div>
</section>
<div class="modal fade" role="dialog" id="contract"
     aria-labelledby="title">
  <form name="myForm" novalidate id="form">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <button type="button" class="close" ng-click="cancel();"
                  aria-label="Close">
            <span aria-hidden="true">&times;</span>
          </button>
          <h4 class="modal-title">{{title}}</h4>
        </div>
        <div class="modal-body">
          <div class="container-fluid">
            <div class="row">
              <div class="col-xs col-md-6">
                <div class="input-group">
										<span class="input-group-addon" id="sizing-addon1">
                                            <i class="fa fa-building"></i>
                                        </span>
                  <input ng-model="contract.cname"
                         type="text" name="cname"
                         class="form-control"
                         aria-describedby="sizing-addon1"
                         placeholder="单位名称" required>
                </div>
                                <span style="color:red"
                                      ng-show="myForm.cname.$dirty && myForm.cname.$invalid">
                                    <span ng-show="myForm.cname.$error.required">单位名称必须填写。</span>
                                </span>
              </div>
              <div class="col-xs col-md-6">
                <div class="input-group">
										<span class="input-group-addon" id="sizing-addon2">
                                            <i class="fa fa-industry "></i>
                                        </span>
                  <select name="pid" required
                          class="form-control select2"
                          ng-model="contract.pid"
                          style="width: 100%;">
                    <option value="" disabled>产品型号</option>
                    <option ng-repeat="product in products"
                            value="{{product.pid}}">{{product.pname}}
                    </option>
                  </select>
                </div>
              </div>
            </div>
            <br/>
            <div class="row">
              <div class="col-xs col-md-6">
                <div class="input-group">
										<span class="input-group-addon" id="sizing-addon1"><i
                      class="fa fa-cny"></i> </span> <input name="money" required
                                                            ng-model="contract.money"
                                                            type="number" class="form-control"
                                                            aria-describedby="sizing-addon1"
                                                            placeholder="合同额（单位为万）">
                </div>
                                    <span
                                      style="color:red"
                                      ng-show="myForm.money.$dirty && myForm.money.$invalid">
											<span ng-show="myForm.money.$error.required">合同额必须填写。</span>
										</span>
              </div>
              <div class="col-xs col-md-6">
                <div class="input-group">
										<span class="input-group-addon" id="sizing-addon2"><i
                      class="glyphicon glyphicon-user"></i> </span> <input
                  name="signperson" required ng-model="contract.signperson"
                  type="text" class="form-control" placeholder="签订人"
                  aria-describedby="sizing-addon2">
                </div>
                                    <span
                                      style="color:red"
                                      ng-show="myForm.signperson.$dirty && myForm.signperson.$invalid">
											<span ng-show="myForm.signperson.$error.required">签订人必须填写。</span>
										</span>
              </div>
            </div>
            <br/>
            <div class="row">
              <div class="col-xs col-md-6">
                <div class="input-group date">
										<span class="input-group-addon"><i
                      class="fa fa-calendar"></i> </span> <input name="signdate" required
                                                                 ng-model="contract.signdate1"
                                                                 type="date"
                                                                 class="form-control"
                                                                 placeholder="签订日期">
                </div>
              </div>
              <div class="col-xs col-md-6">
                <div class="input-group">
										<span class="input-group-addon" id="sizing-addon2"><i
                      class="glyphicon glyphicon-globe"></i> </span> <select
                  name="province" required ng-model="contract.province"
                  class="form-control select2" style="width: 100%;">
                  <option value="" disabled>省份</option>
                  <option ng-repeat="province in provinces"
                          value="{{province.id}}">{{province.name}}
                  </option>
                </select>
                </div>
              </div>
            </div>
            <br/>
            <div class="row">
              <div class="col-xs col-md-6">
                <div class="input-group">
										<span class="input-group-addon" id="sizing-addon1"><i
                      class="fa fa-database"></i> </span> <input name="material" required
                                                                 ng-model="contract.material"
                                                                 type="text"
                                                                 class="form-control"
                                                                 aria-describedby="sizing-addon1"
                                                                 placeholder="物料">
                </div>
                                    <span
                                      style="color:red"
                                      ng-show="myForm.material.$dirty
                                        &&myForm.material.$invalid">
											<span ng-show="myForm.material.$error.required">物料必须填写。</span>
										</span>
              </div>
              <div class="col-xs col-md-6">
                <div class="input-group">
										<span class="input-group-addon" id="sizing-addon2"><i
                      class="fa fa-gears "></i> </span> <select name="purpose" required
                                                                ng-model="contract.purpose"
                                                                class="form-control select2"
                                                                style="width: 100%;">
                  <option value="" disabled>用途</option>
                  <option ng-repeat="purpose in purposes"
                          value="{{purpose.pid}}">{{purpose.pname}}
                  </option>
                </select>
                </div>
              </div>
            </div>
            <br/>
            <div class="row">
              <div class="col-xs col-md-6">
                <div class="input-group">
										<span class="input-group-addon" id="sizing-addon1"><i
                      class="fa fa-legal "></i> </span> <select name="category" required
                                                                ng-model="contract.category"
                                                                class="form-control select2"
                                                                style="width: 100%;">
                  <option value="" disabled>行业</option>
                  <option ng-repeat="category in categories"
                          value="{{category.cid}}">{{category.cname}}
                  </option>
                </select>
                </div>
              </div>
              <div class="col-xs col-md-6">
                <div class="input-group">
										<span class="input-group-addon" ihd="sizing-addon2"><i
                      class="fa  fa-arrows-h"></i> </span> <input name="scale" required
                                                                  ng-model="contract.scale"
                                                                  type="text"
                                                                  class="form-control"
                                                                  placeholder="规模"
                                                                  aria-describedby="sizing-addon2">
                </div>
                                    <span
                                      style="color:red"
                                      ng-show="myForm.scale.$dirty && myForm.scale.$invalid">
											<span ng-show="myForm.scale.$error.required">规模必须填写。</span> </span>
              </div>
            </div>
            <hr/>
            <div class="row">
              <div class="box">
                <div class="box-header">
                  <h3 class="box-title">
                    备注
                    <small>关于合同的一些要求和细节问题</small>
                  </h3>
                  <!-- tools box -->
                  <div class="pull-right box-tools">
                    <button type="button" class="btn btn-default btn-sm"
                            data-widget="collapse" data-toggle="tooltip"
                            title="隐藏">
                      <i class="fa fa-minus"></i>
                    </button>
                  </div>
                  <!-- /. tools -->
                </div>
                <!-- /.box-header -->
                <div class="box-body pad">
											<textarea class="textarea" id="textarea"
                                placeholder="留下点什么吧。。。"
                                style="width: 100%; height: 200px; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;"></textarea>
                </div>
              </div>
            </div>
          </div>
          <div class="modal-footer">
            <button type="button" class="btn btn-default"
                    ng-click="cancel();">取消
            </button>
            <button type="button" class="btn btn-primary" ng-click="save();"
                    ng-disabled="!myForm.$valid">
              保存
            </button>
          </div>
        </div>
        <!-- /.modal-content -->
      </div>
      <!-- /.modal-dialog -->
    </div>
    <!-- /.modal -->
  </form>
</div>
<div class="modal fade" id="contractInfo">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">×</span></button>
        <h4 class="modal-title">合同详情</h4>
      </div>
      <div class="modal-body">
        <div class="box box-primary">
          <div class="box-header with-border">
            <h3 class="box-title">基本信息</h3>
          </div>
          <!-- /.box-header -->
          <div class="box-body">
            <div class="row">
              <div class="col-xs col-sm-6">
                <strong><i class="fa fa-map-marker margin-r-5"></i> 省份</strong>
                <p class="text-muted ">{{cttInfo.provinceName}}</p>
              </div>
              <div class="col-xs col-sm-6">
                <strong><i class="fa fa-book margin-r-5"></i> 产品类型</strong>
                <p class="text-muted">{{cttInfo.productName}}</p>
              </div>
            </div>
            <div class="row">
              <div class="col-xs col-sm-6">
                <strong><i class="fa fa-user margin-r-5"></i> 签订人</strong>
                <p class="text-red"><strong>{{cttInfo.signperson}}</strong></p>
              </div>
              <div class="col-xs col-sm-6">
                <strong><i class="fa fa-calendar margin-r-5"></i> 签订时间</strong>
                <p class="text-muted">{{cttInfo.signdate}}</p>
              </div>
            </div>

            <hr>
            <div class="row">
              <div class="col-xs col-sm-10">
                <strong><i class="fa fa-lock margin-r-5"></i> 合同号</strong>
                <p class="text-muted pull-right">{{cttInfo.cid}}</p>
              </div>
            </div>
            <div class="row">
              <div class="col-xs col-sm-10">
                <strong><i class="fa fa-info margin-r-5"></i> 相关信息</strong>
                <p class="pull-right">
                  <span class="label label-purple">{{cttInfo.provinceName}}</span>
                  <span class="label label-danger">{{cttInfo.money}}万</span>
                  <span class="label label-success">{{cttInfo.material}}</span>
                  <span class="label label-info">{{cttInfo.purposeName}}</span>
                  <span class="label label-warning">{{cttInfo.scale}}</span>
                  <span class="label label-primary">{{cttInfo.categoryName}}</span>
                </p>
              </div>
            </div>
          </div>
        </div>
        <div class="box box-primary">
          <div class="box-header with-border">
            <h3 class="box-title">所属单位</h3>
          </div>
          <!-- /.box-header -->
          <div class="box-body">
            <div class="row">
              <div class="col-xs col-sm-6">
                <strong><i class="fa fa-pencil margin-r-5"></i> 单位名称</strong>
                <p class="text-red"><strong>{{cttInfo.cname}}</strong></p>
              </div>
              <div class="col-xs col-sm-6">
                <strong><i class="fa fa-map-marker margin-r-5"></i> 单位地址</strong>
                <p class="text-muted">{{cttInfo.companyAddress}}</p>
              </div>
            </div>
          </div>
        </div>
        <div class="box box-primary">
          <div class="box-header with-border">
            <h3 class="box-title">相关说明</h3>
          </div>
          <!-- /.box-header -->
          <div class="box-body">
            <strong><i class="fa fa-file-text-o margin-r-5"></i> 备注</strong>
            <p class="text-muted" ng-bind-html="cttInfo.remark"></p>
          </div>
        </div>
        <!-- /.box-body -->
      </div>
    </div>
  </div>
  <!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
<!-- /.modal -->
</div>
